<%@ page import="com.employeemanagementsystem.model.User" %>
<%@ page import="com.employeemanagementsystem.model.Feedback" %>
<%@ page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>员工主页</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f9f9f9;
            padding: 20px;
        }
        h1 {
            color: #333;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        th, td {
            border: 1px solid #ccc;
            padding: 10px;
            text-align: center;
        }
        th {
            background-color: #f2f2f2;
        }
        a {
            display: inline-block;
            margin-top: 15px;
            color: #007BFF;
            text-decoration: none;
        }
        a:hover {
            text-decoration: underline;
        }
        .info-box {
            border: 1px solid #ddd;
            padding: 15px;
            background-color: #fff;
            margin-bottom: 20px;
            border-radius: 6px;
        }
        .feedback-table {
            margin-top: 20px;
        }
        .no-feedback {
            color: #666;
        }
    </style>
</head>
<body>

<%
    User user = (User) session.getAttribute("user");
    if (user == null) {
        response.sendRedirect("login.jsp?error=Session expired. Please log in again.");
        return;
    }

    List<Feedback> feedbacks = (List<Feedback>) request.getAttribute("feedbacks");
%>

<h1>欢迎, <%= user.getFullName() %>!</h1>

<div class="info-box">
    <h2>您的信息:</h2>
    <ul>
        <li>用户名: <%= user.getUsername() %></li>
        <li>邮箱: <%= user.getEmail() %></li>
        <li>部门: <%= user.getDepartment() %></li>
        <li>职位: <%= user.getPosition() %></li>
        <li>入职日期: <%= user.getHireDate() %></li>
    </ul>
</div>

<div class="feedback-table">
    <h2>您的反馈:</h2>
    <table>
        <tr>
            <th>内容</th>
            <th>状态</th>
            <th>回复</th>
        </tr>
        <%
            if (feedbacks != null && !feedbacks.isEmpty()) {
                for (Feedback feedback : feedbacks) {
        %>
        <tr>
            <td><%= feedback.getContent() %></td>
            <td><%= "PENDING".equals(feedback.getStatus()) ? "待处理" : "已处理" %></td>
            <td><%= feedback.getResponse() != null ? feedback.getResponse() : "<span class='no-feedback'>暂无回复</span>" %></td>
        </tr>
        <%
            }
        } else {
        %>
        <tr>
            <td colspan="3"><span class="no-feedback">暂无反馈记录。</span></td>
        </tr>
        <%
            }
        %>
    </table>
</div>

<a href="submit_feedback">提交新反馈</a>&nbsp;&nbsp;
<a href="logout">退出登录</a>

</body>
</html>
